import { request } from '@inbiz/utils';

const version = InbizConfig.API_VERSION
// 获取分组列表数据
export const getFormGroupData = (params?: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPageGroup/treeList`, {
    method: 'GET',
    params,
    appId: params.appId
  });
};

// 添加分组
export const addFormGroup = (params: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPageGroup`, {
    method: 'POST',
    data: params,
    appId: params.appId
  });
};

// 修改分组
export const editFormGroup = (params: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPageGroup`, {
    method: 'PUT',
    data: params,
    appId: params.appId
  });
};

// 删除分组
export const deleteFormGroup = (params: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPageGroup`, {
    method: 'DELETE',
    data: params,
    appId: params.appId
  });
};

// 获取表单列表数据
export const getFormListData = (params?: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPage/loadPageList`, {
    params,
    appId: params.appId
  });
};

// 添加流程表单
export const addProcessForm = (params: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPage/page`, {
    method: 'POST',
    data: params,
    appId: params.appId
  });
};

// 修改表单
export const editFormData = (params: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPage/editPage`, {
    method: 'POST',
    data: params,
    appId: params.appId
  });
};

// 删除表单
export const deleteFormData = (params: any) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPage`, {
    method: 'DELETE',
    data: params,
    appId: params.appId
  });
};

// 导入表单
export const importFormData = (params: any, appId: string) => {
  return request(`/inbiz/api/services/wfpage/v${version}/wfPage/updateImport`, {
    method: 'POST',
    data: params,
    appId: appId
  });
};

// 获取站点列表
export async function getAppList() {
  return request(
    `/inbiz/api/services/engines/v${InbizConfig.API_VERSION}/app/pagedList`,
    {
      params: {
        SkipCount: 0,
        MaxResultCount: 1000,
        keyWords: '',
      },
    },
  );
}